# reference https://github.com/trion-development/docker-ng-cli
FROM node:10.16.0

ARG NPM_REGISTRY="http://172.16.1.161:30033/repository/npm-group/"

ENV CHROME_BIN=/usr/bin/google-chrome

ADD ./ci/base/xvfb-chromium /usr/bin/xvfb-chromium
ADD ./ci/base/xvfb-chromium-webgl /usr/bin/xvfb-chromium-webgl

# 更新源列表
COPY ./ci/base/sources.list /etc/apt/sources.list

RUN set -xe \
  && apt-get update \
  && apt-get install -y \
      xvfb \
      libosmesa6 \
      libgconf-2-4 \
 && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
 && (dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install; rm google-chrome-stable_current_amd64.deb; apt-get clean; rm -rf /var/lib/apt/lists/* ) \
 && chmod -R 755 /usr/bin \
 && mv /usr/bin/google-chrome /usr/bin/google-chrome.real  \
 && mv /opt/google/chrome/google-chrome /opt/google/chrome/google-chrome.real  \
 && rm /etc/alternatives/google-chrome \
 && ln -s /opt/google/chrome/google-chrome.real /etc/alternatives/google-chrome \
 && ln -s /usr/bin/xvfb-chromium /usr/bin/google-chrome \
 && ln -s /usr/bin/xvfb-chromium /usr/bin/chromium-browser \
 && ln -s /usr/lib/x86_64-linux-gnu/libOSMesa.so.6 /opt/google/chrome/libosmesa.so \
 && npm config set registry $NPM_REGISTRY \
 && npm install -g yarn
